package com.d3works.apps.account.service.invoice.factory;

import com.d3works.apps.account.db.Invoice;
import com.d3works.apps.account.db.repo.InvoiceRepository;
import com.d3works.apps.account.service.invoice.workflow.ventilate.VentilateAdvancePaymentState;
import com.d3works.apps.account.service.invoice.workflow.ventilate.VentilateState;
import com.d3works.inject.Beans;

public class VentilateFactory {

  public VentilateState getVentilator(Invoice invoice) {
    VentilateState ventilateState;
    if (invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) {
      ventilateState = Beans.get(VentilateAdvancePaymentState.class);
    } else {
      ventilateState = Beans.get(VentilateState.class);
    }
    ventilateState.init(invoice);
    return ventilateState;
  }
}
